﻿@using SCMS.Resources
@model SCMS.UI.Models.POModel
@{
    int itemCount = Model.POItems == null ? 0 : Model.POItems.Count;
    AjaxOptions ajaxOpts = new AjaxOptions
      {
          UpdateTargetId = "PODiv",
          LoadingElementId = "loading",
          HttpMethod = "Post",
          Url = Url.Action("UpdatePOTender"),
          OnBegin = "return VerifyEditPO(" + itemCount + ")"
      };
}
<script src="@Url.Content("~/Scripts/js/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>@Resources_frank.PurchaseOrder_String_EditPO:: &nbsp;@Model.POEntiy.RefNumber&nbsp;(@Resources_frank.PurchaseOrder_String_FromTA)</h3>
    </div>
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        @Html.ValidationSummary(true)
        <br />
        <table width="98%" align="center" style="margin-left: auto; margin-right: auto;">
            <tr>
                <th>
                    @Resources_frank.Global_String_Date
                </th>
                <th>
                    @Resources_frank.Global_String_TenderAnalyaisNo
                </th>
                <th>
                    @Resources_frank.Global_String_OrderRequestNo
                </th>
            </tr>
            <tr>
                <td>
                    @Html.EditorFor(m => m.PODate)
                    @Html.ValidationMessageFor(m => m.PODate)
                    @Html.HiddenFor(m => m.POEntiy.Id)
                </td>
                <td>
                    @Model.POEntiy.TenderAnalysi.RefNumber
                </td>
                <td>
                    @Model.POEntiy.OrderRequest.RefNumber
                </td>
            </tr>
            <tr>
                <th>
                    @Resources_frank.Budget_CategoryList_ProjectNo
                </th>
                <th>
                    @Resources_frank.PurchaseOrder_String_QuotationRef
                </th>
                <th>
                    @Resources_frank.GoodsReceivedNote_LoadGRNVerifyItems_DeliveryDate
                </th>
            </tr>
            <tr>
                <td>
                    @Model.POEntiy.ProjectDonor.ProjectNumber
                </td>
                <td>
                    @Html.TextBoxFor(model => model.QuatationRef)                    
                    @Html.ValidationMessageFor(model => model.QuatationRef)
                </td>
                <td>@Html.EditorFor(model => model.deliveryDate)
                    @Html.ValidationMessageFor(model => model.deliveryDate)
                </td>
            </tr>
            <tr>
                <th>
                    @Resources_frank.PurchaseOrder_EditPO_ToSupplier
                </th>
                <th>
                    @Resources_frank.Global_String_DeliveryAddress
                </th>
                <th>
                    @Resources_frank.Global_String_DRCRemarks
                </th>
            </tr>
            <tr>
                <td>
                    @Model.POEntiy.Supplier.Name
                </td>
                <td>
                    @Html.DropDownListFor(x => x.deliveryAddressID, Model.deliveryAddress, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(x => x.deliveryAddressID)
                </td>
                <td>
                    @Html.EditorFor(model => model.POEntiy.Remarks)
                </td>
            </tr>
            <tr>
                <th>
                    @Resources_frank.Global_String_ShippingTerms
                </th>
                <th>
                    @Resources_frank.Global_String_PaymentTerms
                </th>
                <th>
                    @Resources_frank.Global_String_Currency
                </th>
            </tr>
            <tr>
                <td>
                    @Html.DropDownListFor(x => x.shippingTerm, Model.ShippingTerms)
                    @Html.ValidationMessageFor(x => x.shippingTerm)
                </td>
                <td>
                    @Html.DropDownListFor(x => x.paymentTerm, Model.PaymentTerms)
                    @Html.ValidationMessageFor(x => x.paymentTerm)
                </td>
                <td align="center">
                    @Model.POEntiy.Currency.ShortName
                    @Html.HiddenFor(m => m.POEntiy.CurrencyId, new { id = "currencyId" })
                </td>
            </tr>
        </table>
        <h4 style="text-align: center;">
            @Resources_frank.PurchaseOrder_String_PurchaseOrderItems</h4>
        <hr />
        <p id="budgetCheckStatus">
        </p>
        <table width="98%" align="center" cellspacing="0" cellpadding="0" border="1" class="cardTable">
            <tr class="grideven">
                <th>
                    @Resources_frank.Global_String_Item
                </th>
                <th>
                    @Resources_frank.Global_String_Description
                </th>
                <th>
                    @Resources_frank.Global_String_Qty
                </th>
                <th>
                    @Resources_frank.PurchaseOrder_AddPOItems_UnitPrice
                </th>
                <th>
                    @Resources_frank.PurchaseOrder_AddPOItems_TotalPrice
                </th>
                <th>
                    @Resources_frank.Budget_CreateSubLine_LineNumber
                </th>
                <th>
                    @Resources_morgan.Global_String_Remarks
                </th>
            </tr>
            @{string row = ""; }
            @for (int i = 0; i < Model.POItems.Count; i++)
            {
                row = "row" + i;
                <tr id="@row">
                    <td style="width: 17%;">
                        @Model.POItems[i].ItemName
                        @Html.HiddenFor(m => m.POItems[i].EntityPOItem.Id)
                        @Html.HiddenFor(m => m.POItems[i].EntityPOItem.OrderRequestItemId, new { @id = "orItem" + i })
                    </td>
                    <td style="width: 25%;">
                        @Model.POItems[i].EntityPOItem.OrderRequestItem.ItemDescription
                    </td>
                    <td style="width: 8%;">
                        @Html.TextBoxFor(m => m.POItems[i].Quantity, new { id = "quantity" + i, onblur = "javascript:computePOItemTotals(" + i + ")", @class = "numericTb" })
                        @Html.ValidationMessageFor(m => m.POItems[i].Quantity)
                    </td>
                    <td style="width: 10%;">
                        @Html.TextBoxFor(m => m.POItems[i].UnitCost, new { id = "unitPrice" + i, onblur = "javascript:computePOItemTotals(" + i + ")", @class = "numericTb" })
                        @Html.ValidationMessageFor(m => m.POItems[i].UnitCost)
                    </td>
                    <td style="width: 10%;">
                        @Html.TextBoxFor(m => m.POItems[i].TotalCost, new { id = "totalPrice" + i, @class = "numericTb", @readonly = "readonly" })
                        @Html.ValidationMessageFor(m => m.POItems[i].TotalCost)
                    </td>
                    <td style="width: 15%;" align="center">
                        @Html.DropDownListFor(m => m.POItems[i].BudgetLineId, Model.POItems[i].BudgetLines, new { @id = "blId" + i, onchange = "javascript:checkBLBalance(" + i + ")" })
                    </td>
                    <td style="width: 15%;">
                        @Html.TextBoxFor(m => m.POItems[i].Remarks)
                    </td>
                </tr>
            }
        </table>
        <table width="98%" align="center">
            <tr>
                <td width="100%" align="right"><input type="submit" class="btn green" value="@Resources_frank.Global_String_Proceed" /></td>
            </tr>
        </table>
    }
</div>
